<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/jqueryui/jquery-1.6.2.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/common/ztree/jquery.ztree.all-3.4.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/common/ztree/zTreeStyle.css"
	type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/ztree/jquery.ztree.excheck-3.5.js"></script>

<link rel="stylesheet" href="<%=request.getContextPath()%>/common/jqueryui/themes/base/jquery.ui.all.css" type="text/css"></link>
<link rel="stylesheet" href="<%=request.getContextPath()%>/common/jqueryui/themes/base/jquery.ui.autocomplete.css" type="text/css"></link>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/jqueryui/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/jqueryui/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/jqueryui/ui/jquery.ui.autocomplete.js"></script>
<script type="text/javascript">
	var zTreeObj;
	setting = {
		view: {
			showLine: false,
			fontCss : {color:"green"}
		},
		callback: {
			onClick: zTreeOnClick
		}
	};
	
	function zTreeOnClick(event, treeId, treeNode) {
	    window.parent.setSecondBox(treeNode.name,treeNode.id);
	};
	
	$(document).ready(function() {
		var teachersName=[]; //存放老师姓名
		$.ajax({
			type:"post",
			url:"<%=request.getContextPath()%>/sys/getSecondTree.do",
			dataType:"json",
			async:false,
			success:function(zTreeNodes){
				$.map(zTreeNodes,function(obj){
					teachersName.push(obj.name);
				});
				zTreeObj = $.fn.zTree.init($("#tree"), setting, zTreeNodes);
			}
		});
		
		$( "#tags" ).autocomplete({
				source: teachersName,
				select: function( event, ui ) {
					var node = zTreeObj.getNodeByParam("name",ui.item.value , null);
					zTreeOnClick(null,null,node);
				}
			});	
	});
</script>
</head>
<body>
			<input style="font-size: 10px" size="15" id="tags" placeholder="快速检索">
	<ul id="tree" class="ztree" style="width:230px; overflow:auto;"></ul>
</body>
</html>